#include "junix.h"

unsigned hash_string (const char *s, unsigned b)
{
  unsigned v = 0;

  while (*s)
    v = ( (v*31 + (int)*s++) % b);

  return v;
}

int main(int argc, char **argv)
{
	if(argc!=2)
	{
		fprintf(stderr,"Usage:%s string\n",argv[0]);
		exit(EXIT_FAILURE);
	}

	printf( "%d\n",hash_string( argv[1],5651 ) );
	
	return 0;
}

